package org.example.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.example.Result;
import org.example.service.LoginService;
import org.example.sso.LoginApi;
import org.example.sso.model.entity.UserDO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@Slf4j
@RequiredArgsConstructor
public class LoginController {

    private final LoginService loginService;


    //@Override
    @GetMapping("/login")
    public Result<String> login(@RequestParam(value = "username") String username,
                                @RequestParam(value = "password") String password) {
        return loginService.login(username, password);
    }

    //@Override
    @RequestMapping("/logout")
    public Result<String> logout(HttpServletRequest request) {
        return loginService.logout(request);
    }
}
